﻿using System;
using Microsoft.Practices.Unity;
using VisualWip.Core;
using VisualWip.Core.Interfaces;

namespace VisualWip.Util
{
    public class WorkItemProviderFactory : IWorkItemProviderFactory
    {
        private readonly IUnityContainer _container;

        public WorkItemProviderFactory(IUnityContainer container)
        {
            _container = container;
        }

        #region IWorkItemProviderFactory Members

        public IWorkItemProvider Create(string providerName)
        {
            return _container.Resolve<IWorkItemProvider>(providerName);
        }

        public TWorkItemProvider Create<TWorkItemProvider>(string providerName) where TWorkItemProvider : IWorkItemProvider
        {
            return (TWorkItemProvider) Create(providerName);
        }

        #endregion
    }
}